import facebook
""" In order to allow PendulIM to set user status on their Facebook
    account the follwoing should oocur:

    1. API keys must be validated to allow use of API
    2. A token must be created
    3. User must log in via fb.login()
    4. must create a valid session for user via auth.getSession()
    5. Then we need to redirect user to this URL:
        http://www.facebook.com/authorize.php?api_key=22745cc1f71dd2697ea3167cf89c0fba&v=1.0&ext_perm=publish_stream
        The above allows PendulIM permission to change user's status on
        Facebook
    6. then save the userID
    7. use userID from now on to change the user's status while their
        is a valid session key
    (in other words, while the user is logged into Facebook)
    """

"""
The Problem with session keys:
-> Facebook sends your application a temporary session key that lasts
    an hour or until the user logs out of Facebook. 
-> Seems like even if I grant PendulIM offline access to user information,
    I still need a new session key!
    And the user must login for me to get a session key!!
-> To grant PendulIM offline acces use this URL:
    http://www.facebook.com/authorize.php?api_key=22745cc1f71dd2697ea3167cf89c0fba&v=1.0&ext_perm=offline_access
-> When ever I try to store the session key provided by auth.getSession I get
    invalid parameter error!

-> Seems like, if user wants to change their status they MUST log into FB first,
    which is such a waste of time, why bother using pendulIM when u r already
    logged into FB??

TO DO:
-> Try to find a way to auto log in user to FB so uer does not need to log in
    whenever they want to use the PendulIM status updater.
"""

class Status():
    def _init_(self,parent=None):
        #Must do the following before using Facebook API (Authentication)
        self.login()

    def login(self):
        self.fb = facebook.Facebook('22745cc1f71dd2697ea3167cf89c0fba', '7401614618034bdd36f56ddd6f26ce2d')
        self.fb.auth.createToken()
        self.fb.login()
        self.fb.auth.getSession()
        self.userID = self.fb.users.getLoggedInUser()

    def setFBStatus(self):
        self.fb.status.set('Can you see my status?!?!', self.userID) 

